package com.kingbright.testlibgdx.main;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.kingbright.testlibgdx.utils.Utils;

public class MainRenderer implements ApplicationListener
{
    //绘图用的SpriteBatch 
    private SpriteBatch batch;
    
    private Texture texture;
    
    private BitmapFont font;
    
    @Override
    public void create()
    {
        batch = new SpriteBatch(); //实例化 
        texture = new Texture(Gdx.files.internal("beauty2.jpg"));
        font = new BitmapFont();
        font.setColor(0.5f, 0.2f, 0.6f, 1.0f);
        font.setScale(2);
    }
    
    @Override
    public void dispose()
    {
    }
    
    @Override
    public void pause()
    {
    }
    
    @Override
    public void render()
    {
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); //清屏 
        batch.begin();
        Utils.Image.drawInMiddle(batch, texture);
        font.draw(batch, "I'm a beauty!", 0, Gdx.graphics.getHeight() / 2);
        batch.end();
    }
    
    @Override
    public void resize(int width, int height)
    {
    }
    
    @Override
    public void resume()
    {
    }
}
